package org.linlinjava.litemall.wx.config;
import org.linlinjava.litemall.wx.filter.TraceStreamFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;
/**
 * @author: weilai
 * @date: 2019/12/26
 * @description:
 */
@Configuration
public class FilterConfig {
    /**
     * 注册过滤器
     *
     * @return FilterRegistrationBean
     */
    @Bean
    public FilterRegistrationBean someFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(traceStreamFilter());
        registration.addUrlPatterns("/wx/commodity/*");
        registration.setName("streamFilter");
        registration.setOrder(3);
        return registration;
    }

    /**
     * 实例化StreamFilter
     * @return Filter
     */
    @Bean(name = "traceStreamFilter")
    public Filter traceStreamFilter() {
        return new TraceStreamFilter();
    }
}
